/**
 * 
 */
package com.gwcloud.leetcode.common;

/**
 * @ClassName   : BevelArray 
 * @author      : ganwei 
 * @date        : 2020年5月16日
 * @Description : BevelArray
 */
public class BevelArray {
	public static void main(String[] args){
		int[][] nums = new int[5][5];
		int count = 0;
		//初始化
		for(int i = 0; i < 5; i++){
			for(int j = 0; j < 5; j++){
				nums[i][j] = count++;
			}
		}
		
		//正常遍历
		for(int i = 0; i < 5; i++){
			for(int j = 0; j < 5; j++){
				System.out.print(nums[i][j]);
				System.out.print(" ");
			}
			System.out.println();
		}
		
		System.out.println();
		//斜着遍历
		for(int l = 2; l <= 5; l++){
			for(int i = 0; i <= 5-l; i++){
				int j = l + i - 1;
				System.out.print(nums[i][j]);
				System.out.print(" ");
			}
			System.out.println();
		}
		
	}
}
